package com.thon.service.user.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.thon.dao.user.InstitutionDao;
import com.thon.dao.util.Page;
import com.thon.entity.user.Institution;
import com.thon.service.user.InstitutionService;

@Service
@Transactional
public class InstitutionServiceImpl implements InstitutionService {
	
	@Autowired
	private InstitutionDao institutionDao;

	@Override
	public Institution getInstitutionByUser(Integer userId) {
		return institutionDao.getInstitutionByUser(userId);
	}

	@Override
	public void addInstitution(Institution institution) {
		if(institution.getId()==null)
			institutionDao.save(institution);
		else
			institutionDao.update(institution);
	}

	@Override
	public Page<Institution> findInstitutionByStatus(Byte status, int pageSize,
			int pageNo) {
		Page<Institution> page = new Page<Institution>();
		page.setPageNo(pageNo);
		page.setPageSize(pageSize);
		return institutionDao.findInstutionByStatus(page, status);
	}

	@Override
	public void updateInstitution(Institution institution) {
		institutionDao.update(institution);
	}

}
